//
//  TBCHeaderView.m
//  待定
//
//  Created by EricXie on 15/11/6.
//  Copyright © 2015年 BoyaLee. All rights reserved.
//

#import "TBCHeaderView.h"

@implementation TBCHeaderView

- (instancetype)initWithFrame:(CGRect)frame
{
    if ([super initWithFrame:frame]) {
        [self createSubViews];
    }
    
    return self;
}

- (void)createSubViews
{
    self.headerImageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, self.frame.size.height * 0.7)];
    _headerImageV.backgroundColor = [UIColor lightGrayColor];
    [self addSubview:_headerImageV];
    
    _stationLogo = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH * 0.03, _headerImageV.frame.size.height + HEIGHT * 0.015, WIDTH * 0.1, WIDTH * 0.1)];
    _stationLogo.backgroundColor = [UIColor lightGrayColor];
    _stationLogo.layer.masksToBounds = YES;
    _stationLogo.layer.cornerRadius = WIDTH * 0.05;
    [self addSubview:_stationLogo];
    
    self.stationName = [[BaseLabel alloc] initWithFrame:CGRectMake(_stationLogo.frame.origin.x + _stationLogo.frame.size.width + WIDTH * 0.015, _stationLogo.frame.origin.y + WIDTH * 0.05 - HEIGHT * 0.02, WIDTH * 0.3, HEIGHT * 0.04)];
    _stationName.textColor = [UIColor colorWithRed:0.025 green:0.094 blue:0.336 alpha:1.000];
    _stationName.font = [UIFont systemFontOfSize:15 * SIZE];
    [self addSubview:_stationName];
    
    _listenLabel = [[BaseLabel alloc] initWithFrame:CGRectMake(WIDTH * 0.5, _stationName.frame.origin.y, WIDTH * 0.48, HEIGHT * 0.03)];
    _listenLabel.textAlignment = NSTextAlignmentRight;
    _listenLabel.textColor = [UIColor lightGrayColor];
    _listenLabel.font = [UIFont systemFontOfSize:17 * SIZE];
    [self addSubview:_listenLabel];
    
    self.introduceLabel = [[BaseLabel alloc] initWithFrame:CGRectMake(_stationLogo.frame.origin.x, _stationLogo.frame.origin.y + _stationLogo.frame.size.height, WIDTH, self.frame.size.height * 0.2)];
    _introduceLabel.numberOfLines = 0;
    _introduceLabel.lineBreakMode = 0;
    _introduceLabel.textColor = [UIColor lightGrayColor];
    _introduceLabel.font = [UIFont systemFontOfSize:17 * SIZE];
    [self addSubview:_introduceLabel];
}

- (void)setRadio:(TBCRadioListModel *)radio
{
    [_headerImageV sd_setImageWithURL:[NSURL URLWithString:radio.coverimg]];
    [_stationLogo sd_setImageWithURL:[NSURL URLWithString:radio.userModel.icon]];
    _stationName.text = radio.userModel.uname;
    _listenLabel.text = [NSString stringWithFormat:@"收听:%ld", radio.count];
    _introduceLabel.text = radio.desc;
}

@end
